/*
 * @Overview:   types
 * @Author:     Zi_Jun
 * @Email:      zijun2030@163.com
 * @Date:       2020/12/7 11:36
 * @Mark:       //
 */
import { AxiosRequestConfig, Canceler, AxiosInstance, AxiosResponse } from 'axios';
import { AxiosTransform } from './axios-transform';

export type IAxiosRequestConfig = AxiosRequestConfig;
export type IAxiosInstance = AxiosInstance;
export type IAxiosResponse = AxiosResponse;
export type ICanceler = Canceler;

export interface IRequestOptions {
  // 是否隐藏接口请求loading
  isHideRequestLoading?: boolean;
  // 是否忽略重复请求
  isIgnoreCancelToken?: boolean;
  // 是否处理请求结果
  isTransformRequestResult?: boolean;
  // 错误消息提示类型
  errorMessageMode?: 'none' | 'modal';
}

export interface ICreateAxiosOptions extends IAxiosRequestConfig {
  transform?: AxiosTransform;
  requestOptions?: IRequestOptions;
}

export interface IResult<T = any> {
  code: number;
  type: 'success' | 'error' | 'warning';
  message: string;
  result: T;
}

export interface IUploadFileParams {
  data?: { [key: string]: any };
  name?: string;
  file: File | Blob;
  filename?: string;
  [key: string]: any;
}
